<template>
<slot :controller="controller" :store="store" :model="model" :actions="{ handleItemClick, handleDragChange, handleItemDbClick }">
      <AppKanBan
        v-bind="$attrs"
        :id="controlID"
        :class="classNames"
        :items="store.data"
        :selections="store.selections"
        @item-click="handleItemClick"
        @drag-change="handleDragChange"
        @item-db-click="handleItemDbClick">
      </AppKanBan>
</slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@KANBAN}}-kanban/{{spinalCase ctrl.codeName}}-kanban-base.vue.hbs生成
import { AppKanBan } from '@components/widgets/kanban';
import { useProps, useBasic, useAction, useController } from './has-panel-kan-ban-kanban-hook';
import { KanBanActionType, IKanBanAbility, IKanBanStore, IParam, IViewLogicInput } from "@/core/interface";

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { controlID, getClassNames, model ,useNavParamsBind, useEventBind, handleActionClick, handleComponentAction } = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: KanBanActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: IKanBanAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
//  部件样式名
const classNames = computed(() => {
  return getClassNames(props);
});

//  看板部件控制器
const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: IKanBanStore = controller.getStore();

const  { handleItemClick, handleItemDbClick, handleDragChange} = useAction(controller);

onMounted(() => {
    controller.ctrlMounted();
});
onUnmounted(() => {
    controller.ctrlDestroy();
})
</script>